package com.gelsanalyzer.application;

import java.awt.*;
import java.beans.*;

import javax.swing.*;

import org.apache.log4j.*;

import com.gelsanalyzer.core.*;
import com.gelsanalyzer.mvc.controller.*;
import com.gelsanalyzer.mvc.view.*;

public class CourseOptimizerView extends AbstractViewPanel {
    private static final Logger log = Logger.getLogger(CourseOptimizerView.class);


    public CourseOptimizerView() {       
        initComponents();
        doTheLayout();
    }

    // make all the objects
    public void initComponents() {
        optimizedTextArea = new JTextArea();
        
        buttonOptimize = new JButton(ActionFactory.getOptimizeCourse());
        
        // put table in scrolling pane
        tablePane = new JScrollPane(optimizedTextArea);
        doTheLayout();
    }

    // Layout all the objects
    private void doTheLayout() {
        setLayout(new BorderLayout());
        add(new JPanel().add(buttonOptimize),BorderLayout.NORTH);
        add(tablePane,BorderLayout.CENTER);
    }

    public void setTextArea(String s) {
        optimizedTextArea.setText(s);
    }

    // Variables declaration
    private javax.swing.JScrollPane tablePane;
    private JTextArea optimizedTextArea;
    private JButton buttonOptimize;
    // End of variables declaration

    public void modelPropertyChange(PropertyChangeEvent event) {
         if ( event.getPropertyName().equals("UpdateOptimizerView") ) {
             log.info("OPTIMIZE THE courselist.");
             optimizedTextArea.setText(event.getNewValue().toString());
         }        
    }
}